cmake_minimum_required(VERSION 3.22)
project(Sofa.Component.Engine.Select LANGUAGES CXX)

set(SOFACOMPONENTENGINESELECT_SOURCE_DIR "src/sofa/component/engine/select")

set(HEADER_FILES
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/config.h.in
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/init.h
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/BaseROI.h
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/BaseROI.inl
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/BoxROI.h
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/BoxROI.inl
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/ComplementaryROI.h
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/ComplementaryROI.inl
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/IndicesFromValues.h
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/IndicesFromValues.inl
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/MergeROIs.h
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/MeshBoundaryROI.h
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/MeshROI.h
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/MeshROI.inl
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/MeshSampler.h
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/MeshSampler.inl
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/MeshSplittingEngine.h
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/MeshSplittingEngine.inl
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/MeshSubsetEngine.h
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/MeshSubsetEngine.inl
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/NearestPointROI.h
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/NearestPointROI.inl
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/PairBoxRoi.h
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/PairBoxRoi.inl
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/PlaneROI.h
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/PlaneROI.inl
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/PointsFromIndices.h
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/PointsFromIndices.inl
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/ProximityROI.h
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/ProximityROI.inl
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/SelectConnectedLabelsROI.h
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/SelectLabelROI.h
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/SphereROI.h
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/SphereROI.inl
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/SubsetTopology.h
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/SubsetTopology.inl
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/ValuesFromIndices.h
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/ValuesFromIndices.inl
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/ValuesFromPositions.h
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/ValuesFromPositions.inl
)

set(SOURCE_FILES
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/init.cpp
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/BoxROI.cpp
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/ComplementaryROI.cpp
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/IndicesFromValues.cpp
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/MergeROIs.cpp
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/MeshBoundaryROI.cpp
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/MeshROI.cpp
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/MeshSampler.cpp
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/MeshSplittingEngine.cpp
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/MeshSubsetEngine.cpp
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/NearestPointROI.cpp
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/PairBoxRoi.cpp
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/PlaneROI.cpp
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/PointsFromIndices.cpp
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/ProximityROI.cpp
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/SelectConnectedLabelsROI.cpp
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/SelectLabelROI.cpp
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/SphereROI.cpp
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/SubsetTopology.cpp
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/ValuesFromIndices.cpp
    ${SOFACOMPONENTENGINESELECT_SOURCE_DIR}/ValuesFromPositions.cpp

)

sofa_find_package(Sofa.Simulation.Core REQUIRED)

add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Simulation.Core)

sofa_create_package_with_targets(
    PACKAGE_NAME ${PROJECT_NAME}
    PACKAGE_VERSION ${Sofa_VERSION}
    TARGETS ${PROJECT_NAME} AUTO_SET_TARGET_PROPERTIES
    INCLUDE_SOURCE_DIR "src"
    INCLUDE_INSTALL_DIR "${PROJECT_NAME}"
)

# Tests
# If SOFA_BUILD_TESTS exists and is OFF, then these tests will be auto-disabled
cmake_dependent_option(SOFA_COMPONENT_ENGINE_SELECT_BUILD_TESTS "Compile the automatic tests" ON "SOFA_BUILD_TESTS OR NOT DEFINED SOFA_BUILD_TESTS" OFF)
if(SOFA_COMPONENT_ENGINE_SELECT_BUILD_TESTS)
    enable_testing()
    add_subdirectory(tests)
endif()
